package collections_1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class api_often {
    public static void main(String[] args) {
        List<String> l=new ArrayList<>();
        //1.添加
        Collections.addAll(l,"朱佳铖","李佳辉","杨杨");//也可以加数组
        System.out.println(l);
        //2.打乱list集合顺序
        Collections.shuffle(l);
        System.out.println(l);
        //3.排序1默认升序并且内容具有排序意义
        List<Integer> list=new ArrayList<>();
        Collections.addAll(list,6,8,7,60);
        Collections.sort(list);
        System.out.println(list);//[6, 7, 8, 60]
        //4.排序2制定排序规则和set的treeset排序类似只是如果前一个元素减去后一个元素等于0的话不会去重
        Collections.sort(list, (o1,o2) -> o2-o1);
        System.out.println(list);//[60, 8, 7, 6]

    }
}
